package com.gayworld.service.model;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gayworld.controller.helper.MessageResourcesI18n;
import com.gayworld.controller.vo.ActionVO;
import com.gayworld.controller.vo.IconVO;
import com.gayworld.model.dao.PlacesDAO;
import com.gayworld.model.entity.Places;
import com.gayworld.model.noentity.Icon;

@Service
@Transactional
public class PlacesServiceImpl implements PlacesService {

	@Autowired
	private PlacesDAO placesDAO;
	
	@Autowired
	private ActionService actionService;
	
	@Autowired
	private MessageResourcesI18n message;


	@Override
	public List<Places> findInsideOfSquare(Double neLongitud,
			Double neLatitude, Double swLongitud, Double swLatitude,
			List<Integer> iList, int maxResult) {
		return placesDAO.findInsideOfSquare(neLongitud, neLatitude, swLongitud, swLatitude, iList, maxResult);
	}	
	
	 
	@Override
	public void removePlace(ActionVO actionVO) {
		 
		//TODO envolverlo en try catch y lanzar una excepcion customizada diciendo que error en darlo de baja
		
		
		actionService.create(actionVO);
	}	
	
	@Override
	public List<IconVO> getIconList() {
		 
		List<IconVO> iconList = new ArrayList<IconVO>();
		
		for(Icon i : Icon.values()){
			IconVO iconVO = new IconVO();
			BeanUtils.copyProperties(i, iconVO);
			iconList.add(iconVO);
		}
		return iconList;
	}	
	
	
	
	public void setPlacesDAO(PlacesDAO placesDAO) {
		this.placesDAO = placesDAO;
	}


	/**
	 * @param actionService the actionService to set
	 */
	public void setActionService(ActionService actionService) {
		this.actionService = actionService;
	}
}
